const { getPhone, ruleList } = require("../../../../../utils/api")

// pages/signinpage/component/rule-dialog/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false
    },
    fatherData: {
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    showRule: false

  },

  /**
   * 组件的方法列表
   */
  methods: {
    closePhone() {
      this.setData({
        show: false
      })
    },

    getPhoneNumber(e) {
      let that = this

      if (e.detail.errMsg == 'getPhoneNumber:ok') {
        let params = {
          code: e.detail.code
        }
        getPhone(params).then((res) => {
          if (res.errcode == 0) {
            wx.showToast({
              title: '手机号绑定完成',
              icon: 'success',
              duration: 1500,
              success: (result) => {
                setTimeout(function () {
                  that.triggerEvent("fatherFun");
                  that.setData({
                    show: false
                  })
                }, 1000);

              },

            });

          } else {
            wx.showToast({
              title: res.errmsg,
              icon: 'none',

            });

          }
        })
      } else {

      }
    },




    toAgree() {
      let params = {
        type: "7"
      }
      ruleList(params).then((res) => {
        if (res.errcode == 0) {
          this.setData({
            showRule: true,
            ruleMsg: res.data
          })

        } else {
        }
      })


    },

  }
})
